package com.qmx.qmxapp.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.qmx.qmxapp.MainActivity;
import com.qmx.qmxapp.R;
import com.qmx.qmxapp.base.BaseActivity;
import com.qmx.qmxapp.callback.DialogCallback;
import com.qmx.qmxapp.constant.AppConstant;
import com.qmx.qmxapp.constant.ComParamContact;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class JoinMeetingSetActivity extends BaseActivity {
    @BindView(R.id.edit_terminal_name)
    EditText edit_terminal_name;
    @BindView(R.id.edit_meeting_show_name)
    EditText edit_meeting_show_name;
    @BindView(R.id.rg_join_meeting)
    RadioGroup rg_join_meeting;
    @BindView(R.id.next)
    Button next;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_join_meeting_set);
        ButterKnife.bind(this);

        rg_join_meeting.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.close_video:

                        break;
                    case R.id.close_voice:

                        break;
                }
            }
        });

    }

    public String getTerminalNumber() {
        String number = edit_terminal_name.getText().toString();
        if (TextUtils.isEmpty(number)) {
            showToast("输入终端号/会议号");
            return "";
        }
        return number;
    }


    public String getShowName() {
        String show_name = edit_meeting_show_name.getText().toString();
        if (TextUtils.isEmpty(show_name)) {
            showToast("会议中显示的名字");
            return "";
        }
        return show_name;
    }


    @OnClick(R.id.next)
    public void onclick() {
        doPost();
        startActivity(new Intent(this, MainActivity.class));
    }

    /**
     * TODO
     */
    private void doPost() {
        getTerminalNumber();
        getShowName();
        OkGo.<String>post(AppConstant.Url + ComParamContact.validMobile.PATH)
                .params(ComParamContact.validMobile.AREA_CODE, "+86")
                .params(ComParamContact.validMobile.MOBILE, "")
                .execute(new DialogCallback<String>(this) {

                    @Override
                    public void onSuccess(Response<String> response) {
                        showToast(response.body());
//                            handleResponse(response);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        showToast("接口有问题");
//                            handleError(response);
                    }
                });

    }
}
